<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
	<title>延迟执行</title>
	<style type="text/css">
	#yan{
		background-color:black; 
		width: 300px;
		height: 300px;
	}
	</style>
</head>
<body>
<div id="yan"></div>
<script type="text/javascript">
var oDiv = document.getElementById('yan');
var times1 = setTimeout(function () {
	oDiv.style.backgroundColor = 'green';
	oDiv.innerText = '123123123';
},2000);

var times2 = setTimeout(function () {
	oDiv.style.backgroundColor = 'blue';
	oDiv.innerText = '爱你';
},5000);

var times3 = setTimeout(function () {
	oDiv.style.backgroundColor = 'red';
	oDiv.innerText = '七夕';
},8000);

clearInterval(times2)
</script>
</body>

</html>